package com.example.myapplication;

import android.content.Intent;
import android.content.IntentFilter;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        UsbBroadcast receive = new UsbBroadcast();
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_MEDIA_MOUNTED); //设置广播接收器监听的Action
        registerReceiver(receive, filter);

        setContentView(R.layout.activity_main);
    }




//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
////关闭广播接收器
//        unregisterReceiver( receive );
//    }
}
